<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Session;


class Index extends Controller
{
    public function index()
    {
        $id = Session::get('id');
        // var_dump($id);
        $list2 = Db::table('user_info')->where('uid',$id)->find();
        $c = db('tp_cate')->where('pid','1')->select();
        $t = db('tp_article')->select();
        $this->assign(['tcates'=>$c,'topic'=>$t]);
        $this->assign('id',$id);
        $this->assign('list2',$list2);

        return $this->fetch();
        //分页查询
        //友情链接
        //优秀作品
    }

    public function written()
    {
        $id = Session::get('id');
        $day = Db::table('user_info')->where('uid',$id)->find();
        var_dump($day);
        $w = Db::table('user_info')->where('uid',$id)->update(['written'=>$day['written']+1]);
        var_dump($w);
        return $this->redirect('./index/index');
    }
 
}
